{{- define "content"}}
{{$pages := $.Scratch.Get "pages"}}
<main class="main" role="main">
    <article class="content article article-archives article-type-list" itemscope="">
        <header class="article-header">
            <h1 itemprop="title">{{ .Title }}</h1>
            <p class="text-muted">{{- T "total_article" (len $pages) }}</p>
        </header>
        <div class="article-body">
            {{- $emptyDatePages := slice}}
            {{- $currentYearSection := 0}}
            {{- range $idx,$page := $pages}}
                {{- if $page.Date}}
                    {{- $thisYear := $page.Date.Format ("2006") }}
                    {{- if eq $currentYearSection 0 }}
                        {{- $currentYearSection = $thisYear}}
                    {{- end }}
                    {{- if or (eq $idx 0) (ne $currentYearSection $thisYear)}}
                        {{- if ne $idx 0 }}
                        </div></div></div></section>
                        {{- end}}
                        <section class="panel panel-default b-no">
                            <div class="panel-heading" role="tab">
                                <h3 class="panel-title">
                                    <a data-toggle="collapse" href="#collapse{{- $thisYear }}" aria-expanded="true">
                                        <i class="icon icon-calendar-plus text-active"></i><i class="icon icon-calendar-minus text"></i>
                                        &nbsp;{{- $thisYear }}
                                    </a>
                                </h3>
                            </div>
                            <div id="collapse{{- $thisYear }}" class="panel-collapse collapse in" role="tabpanel"
                                aria-labelledby="heading{{- $thisYear }}">
                                <div class="panel-body">
                                    <div class="collection">
                        {{- $currentYearSection = $thisYear}}
                    {{- end}}
                    {{- .Scratch.Set "type" "link"}}
                    {{- partial "item-post.html" . }}
                {{- else}}
                    {{- $emptyDatePages = $emptyDatePages | append $page}}
                {{- end }}
            {{- end}}
            {{- if $emptyDatePages}} 
            </div></div></div></section>
            <section class="panel panel-default b-no">
                <div class="panel-heading" role="tab">
                    <h3 class="panel-title">
                        <a data-toggle="collapse" href="#collapse-other" aria-expanded="true">
                            <i class="icon icon-calendar-plus text-active"></i><i class="icon icon-calendar-minus text"></i>
                            &nbsp; Other
                        </a>
                    </h3>
                </div>
                <div id="collapse-other" class="panel-collapse collapse in" role="tabpanel"
                    aria-labelledby="heading-other">
                    <div class="panel-body">
                        <div class="collection">
                            {{- range $page := $emptyDatePages}}
                                {{- .Scratch.Set "type" "link"}}
                                {{- partial "item-post.html" . }}
                            {{- end}}
            {{- end }}
        </div></div></div></section>
        </div>
    </article>
</main>
{{- end }}
